using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Microsoft.VisualStudio.Modeling;

namespace DslCrossModelFramework {
    public interface IModelDirectory {
        /// <summary>
        /// Finds all model elements of the specified type.
        /// </summary>
        /// <param name="domainClassId">The domain class id of the type.</param>
        /// <returns>A readonly collection of ModelElements</returns>
        ReadOnlyCollection<ModelElement> FindAllElements(Guid domainClassId);


        ModelElement GetElement(Guid elementId);


        /// <summary>
        /// Gets all the elements found.
        /// </summary>
        /// <returns></returns>
        ReadOnlyCollection<ModelElement> AllElements();

        /// <summary>
        /// Finds all elements in model.
        /// </summary>
        /// <param name="modelRoot">The model root.</param>
        /// <returns></returns>
        ReadOnlyCollection<ModelElement> FindAllElementsInModel(ModelElement modelRoot);

        /// <summary>
        /// Gets all model roots.
        /// </summary>
        /// <returns></returns>
        ReadOnlyCollection<ModelElement> GetAllModelRoots();


        /// <summary>
        /// Gets all model root types.
        /// </summary>
        /// <returns></returns>
        List<Type> GetAllModelRootTypes();


        /// <summary>
        /// Gets all model types.
        /// </summary>
        /// <returns></returns>
        List<Type> GetAllModelTypes();


        /// <summary>
        /// Unloads the model.
        /// </summary>
        /// <param name="modelFileInfo">The model file info.</param>
        void UnloadModel(IModelFileInfo modelFileInfo);

        /// <summary>
        /// Gets the model files.
        /// </summary>
        /// <value>The model files.</value>
        List<IModelFileInfo> ModelFiles{ get; }


        /// <summary>
        /// Gets the name of the current solution.
        /// </summary>
        /// <value>The name of the current solution.</value>
        string CurrentSolutionName { get; }


        /// <summary>
        /// Preloads all model files.
        /// </summary>
        void PreloadAllModelFiles();


        /// <summary>
        /// Gets the model element root for a model element.
        /// </summary>
        /// <param name="modelElement">The model element.</param>
        /// <returns>The root of the model instance</returns>
        ModelElement GetModelElementRoot(ModelElement modelElement);

        /// <summary>
        /// Gets the package info.
        /// </summary>
        /// <param name="modelElement">The model element.</param>
        /// <returns></returns>
        DslToolsPackageInfo GetPackageInfo(ModelElement modelElement);


        ModelElement ResolveModelElementReference(string modelReference, IModelFile modelFile);


        string GetModelElementReference(ModelElement modelElement);

        ModelElement GetModelRoot(IModelFile modelFile);

        IModelFileInfo GetModelFileInfo(ModelElement modelElement);

        bool CanReferenceModelElement(DomainClassInfo domainClassInfo);


        DomainClassInfo GetModelElementRootType(DomainClassInfo domainClassInfo);
    }
}